perm filename HEAD[S,AIL]16 blob sn#093290 filedate 1974-03-26 generic text, type T, neo UTF8
COMMENT ⊗   VALID 00017 PAGES VERSION 17-2(79)
RECORD PAGE   DESCRIPTION
 00001 00001
 00003 00002	HISTORY
 00010 00003	 INTRODUCTION
 00011 00004	  SWITCHES : AN INTRODUCTION
 00016 00005	 SWITCH SETTINGS & MACROS
 00024 00006	 THE FILSPC STUFF -- OLDER HISTORY 
 00026 00007	 FILSPC FILES
 00031 00008	 NARRATIVE FILSPC ACCOUNTS
 00037 00009	LISTING CONTROL MACROS & THE LIKE
 00044 00010	 MACHINE-EXTENDING MACROS (SOME USEFUL CONSTANT, STORAGE/STORAGE MANIPULATORS)
 00049 00011	  TELETYPE COMMUNICATION MACROS
 00052 00012	  INPUT/OUTPUT AIDS
 00055 00013	 RANDOM OTHER MACROS
 00057 00014	TBITS DEFINITIONS
 00062 00015	 VARIOUS DEFINITIONS OF USER UUO'S.
 00064 00016	DSCR USER DATA AREA TEMPLATE  
 00074 00017	Global AC Definitions, Indices, Bits
 00081 ENDMK
⊗;
COMMENT ⊗HISTORY
AUTHOR,REASON
021  202100000117  ⊗;


COMMENT ⊗
VERSION 17-2(79) 3-26-74 BY RLS CHANGE TENEX LOADVR TO 54
VERSION 17-2(78) 3-19-74 BY RHT GO OVER FILE WITH RS
VERSION 17-2(77) 3-17-74 BY RLS  EDIT
VERSION 17-2(76) 3-17-74 BY RLS INSTALL SITE SWITCHES
VERSION 17-2(75) 3-17-74 BY RLS INSTALL TENEX FEATURES, TENEX SYSTEM SWITCHES
VERSION 17-2(75) 2-24-74 BY RHT FEAT %BH% TMPB FOR REF ITEM DATUM
VERSION 17-2(74) 1-11-74 
VERSION 17-2(73) 1-11-74 BY JRL ADD CMU SWITCHES SPACE ALLOCATION COMVER
VERSION 17-2(72) 1-11-74 
VERSION 17-2(71) 1-11-74 
VERSION 17-2(70) 12-9-73 BY KVL %BC% ADD BAIL SWITCH
VERSION 17-2(69) 12-6-73 BY jrl REMOVE AS MANY NON STANFORD CHARS AS POSSIBLE
VERSION 17-2(68) 12-3-73 BY RHT ITMANY←←0
VERSION 17-2(67) 12-3-73 
VERSION 17-2(66) 12-3-73 BY RFS INSERT CALLIS FOR EXPORT SYSTEM
VERSION 17-2(65) 12-3-73 
VERSION 17-2(64) 12-3-73 BY RFS ELIMINATED ALL III DISPLAY STUFF
VERSION 17-2(63) 12-2-73 BY RHT HEREFK MACRO & REMOVE USELESS FILSPC TAPE HISTORY
VERSION 17-2(62) 12-2-73 
VERSION 17-2(61) 11-30-73 BY RHT ADD STANSW & DECSW
VERSION 17-2(60) 11-26-73 
VERSION 17-2(59) 11-26-73 
VERSION 17-2(58) 11-26-73 BY RHT DIDDLE THE FILSPC STUFF
VERSION 17-2(57) 11-24-73 BY RHT FEAT %AM% ALLOW MANY USER PHASES OF INIT
VERSION 17-2(56) 11-24-73 
VERSION 17-2(55) 11-21-73 BY RFS CHANGE 'TEST' TO 'TSTSEG'
VERSION 17-2(54) 11-18-73 
VERSION 17-2(53) 11-18-73 BY RHT FEAT %AJ% -- ADD IN FILSPC
VERSION 17-2(52) 11-18-73 
VERSION 17-2(51) 11-18-73 
VERSION 17-2(50) 11-18-73 
VERSION 17-2(49) 11-18-73 
VERSION 17-2(48) 11-18-73 BY RHT FEAT %AJ% -- RESTRUCTURE HEAD
VERSION 17-2(47) 11-10-73 BY RHT ADD CORERR, ERRPRI, ERFLGS BITS
VERSION 17-1(46) 7-26-73 BY RHT TRY VERSION 17
VERSION 17-1(45) 7-26-73 *********************
VERSION 16-2(44) 7-9-73 BY JRL REMOVE LAST REFERENCES TO DCS SWITCH
VERSION 16-2(43) 4-23-73 BY RHT CHANGE ARGTYP TO RFITYP
VERSION 16-2(42) 2-7-73 BY RHT ADD TYPE FOR ARG LIST ITEM
VERSION 16-2(41) 1-28-73 BY JRL PUT QBIND,FBIND HERE SO STATS CAN USE
VERSION 16-2(40) 1-23-73 BY RHT MAKE NIC & UNBOUND THE SAME
VERSION 16-2(39) 1-23-73 BY JRL CHANGE CODE FOR UNBND
VERSION 16-2(38) 1-8-73 BY JRL ADD MAXLOC MAXIMUM NUMBER OF FOREACH LOCAL ITEMVARS ALLOWED
VERSION 16-2(37) 12-13-72 BY jrl BUG #KS# ADD LOADVR SWITCH
VERSION 16-2(36) 11-21-72 
VERSION 16-2(35) 11-10-72 BY HJS MODIFY QPOP TO TAKE AS AN ARGUMENT AN ADDRESS FOR THE POPPED ENTRY
VERSION 16-2(34) 10-16-72 BY JRL CHANGE INVTYP TO 31 TO ALLOW CONTEXT ARRAY ITEMS
VERSION 16-2(33) 9-15-72 BY RHT ADD USER TABLE ENTRIES FOR INTERRUPTS
VERSION 16-2(32) 8-27-72 BY RHT PUT CELL FOR STACK UNWINDER RET ADRS IN USER TABLE
VERSION 16-2(31) 8-23-72 BY JRL ADD UNBND "ITEM"
VERSION 16-2(30) 8-20-72 BY RHT MODIFY USER TABLE
VERSION 16-2(29) 8-6-72 BY RHT ADD PRILIS TO USER TABLE
VERSION 16-2(28) 8-3-72 BY JRL ADD MPBIND TO TBITS DEFS FOR MATCHING PROCEDURES
VERSION 16-2(27) 7-27-72 BY RHT MAKE MACRO FOR DECLARING PD. ENTRIES
VERSION 16-2(26) 7-20-72 BY JRL CHANGE ARRTYP VALUE
VERSION 16-2(25) 7-20-72 BY RHT ADD PROCESS ITEM (TYPE 11)
VERSION 16-2(24) 6-20-72 BY DCS BUG #HU# BETTER TTY INFORMATION
VERSION 16-2(23) 5-16-72 BY DCS INTRODUCE VERSION 16
VERSION 15-2(9-22) 5-4-72 LOTS OF THINGS
VERSION 15-2(8) 2-19-72 BY RHT THE BRAVE NEW WORLD
VERSION 15-2(7) 2-5-72 BY DCS BUG #GJ# ADD LSTON LISTING CONTROL STUFF
VERSION 15-2(6) 2-5-72 BY DCS BUG #GI# REMOVE TOPSTR DUE TO NEW `CAT'
VERSION 15-2(5) 2-1-72 BY DCS BUG #GE# INSTALL SYMB %ALLOC BLK INDICES
VERSION 15-2(4) 1-31-72 BY DCS BUG #GE# UPDATE USER TABLE, %ALLOC BITS, INDICES
VERSION 15-2(3) 1-3-72 BY DCS BUG #FX# REMOVE COM2, COM2SW COMPLETELY
VERSION 15-2(2) 12-24-71 BY DCS BUG #FF# REMOVE SAILRUN(ASSUME RUNTIM OR LIB)
VERSION 15-2(1) 12-2-71 BY DCS INSTALL VERSION NUMBER

⊗;
COMMENT ⊗ INTRODUCTION
	THIS IS THE FILE OF MACRO DEFINITIONS AND GLOBAL AC
	ASSIGNMENTS FOR THE SAIL COMPILER, THE SAIL RUNTIME
	ROUTINES.  NEEDLESS TO SAY, NOT ALL PORTIONS ARE USED
	BY ALL PEOPLE.
⊗



EXTERNAL  JOBSA,JOBREN,JOBUUO
EXTERNAL JOBSYM,JOBFF,JOBREL,JOB41,JOBDDT,JOBCNI,JOBTPC,JOBUUO
EXTERNAL JOBAPR,JOBHRL



SUBTTL	SAIL/GOGOL MACROS AND SWITCHES
COMMENT ⊗  SWITCHES : AN INTRODUCTION
Conditional assembly runs rampant in SAIL.  Most of the switches are used to
 select options (debug or no debug, etc.) Some are only valid at Stanford.
 There is one, EXPORT, tested by the macros NOEXPO and EXPO, which decides
 whether this is for Stanford or somebody else.

We have a program which, by reading the SAIL files and looking for switch-
 testing macros, can do the conditional assembly once and for all (removing
 the conditional stuff from the files.  It is such a set of files which
 we normally send out, so if you see some switches and macros below that
 never get referenced, it's because that code was taken out of your files.

The conditional assembly switches are assigned in the following files:

DCS	DCS	←2				;SLS (experimental) system
	FTDEBUG ←1				;include debugging in cmplr

;NOCOM	COM2SW	←0				;OBSOLETE SWITCH, WAS TO
						; DISTINGUISH 2-SEG COMPILER
WOM	DCS	←1				;WOM (experimental) system

HEAD	EXPORT	←if NDEF then 0 else EXPORT
	DCS	←if NDEF then 0 else DCS
;	COM2SW	←if NDEF then 1 else 0
	SIXSW	←if NDEF then (if EXPO then 0 else 1) else SIXSW ;sixbit PPN's
	HEDSYM	←if NDEF then 0 else HEDSYM	;With HEDSYM on, assembling HEAD
						; yields HEAD.REL, a symbol
						; file for the USERCON function

GLB	GLOBSW	←1				;runtimes know about glb mdl

LOW	SEGS	←1				;upper or lower assembly
	LOWER	←1				;assembles SAILOW or GLBLOW
	UPPER	←0

UP	SEGS	←1
	LOWER	←0
	UPPER	←1				;assembles UPPER or GLOBAL

FILSPC IS PART OF HEAD AS OF NOV 1973
FILSPC	FILXXX	←SAISGn				;SAIL upper segment name
	SLOFIL	←SAILOW				;SAIL lower segment name
GLOB <
	FILXXX	←GLBSGn				;global model upper segment name
	SLOFIL	←GLBLOW				;global model lower segment name
>;GLOB
	SGDEVC	←SYS				;device for segment files
	SGPPNN	←0				;PPN for segment files
	LOCSYM	←0				;no local uppers in lower file
	NOPROT	←0				;want upper segment protected

DB	FTDEBUG	←1

SAIL	LEAPSW	←1				;LEAP exists
	FTDEBUG	←if NDEF then 0 else FTDEBUG
	GLOBC	←if LEAP and NOEXPO then 1 else if NDEF then 0 else GLOBC
	PATSW	←if NDEF then 0 else PATSW	;compile AOS/SOS to PAT words
	RENSW	←if NDEF then 1 else RENSW	;compile Re-entrant Code
	TMPCSW	←if NDEF then (if EXPO then 1 else 0) else TMPCSW
					;TMPCOR UUO available and used
;; #KS BY JRL (12-13-72) ADD LOADVR SWITCH
	LOADVR  ←if NDEF then 54 else LOADVR (for differences in block code
			for required rel files,libraries in LOADER 54)
	 SAILRUN was a switch controlling some runtimes.  Now runtimes will
	  be assembled to assume a compiler (since that's common anyway).
;; %BC% BY KVL (1/3/74) ADD BAIL SWITCH
	BAISW	←if STANFO then 1 else 0	;Bail only at stanford

GOGOL	UPPER	←if NDEF then 0 else 
	UPPER	←if NDEF then 0 else UPPER
	LOWER	←if NDEF then 0 else LOWER
	SEGS	←UPPER or LOWER
	GLOBSW	←if NDEF then 0 else GLOBSW
	RENSW	←if NDEF then 1 else RENSW	;assemble Upper-Segment Library
	 SAILRUN  no longer exists.
; SWITCH SETTINGS & MACROS

These macros come in pairs, and exist so that the above-mentioned
 program will have an easy job of it.  The meaning of each pair is
 obvious.  They may be used only as in the following example:
SW <			;or NOSW, starting in col. 1 (any comment out here)
(code to appear under this switch)
>;SW			or NOSW, must be same, any comment out here
 These things may be nested without confusing anyone.

Here are the macros
⊗

DEFINE DEC <IFN DECSW,>		;dec 10-50 based system
DEFINE NODEC <IFN DECSW,>	;impossible on DEC sys.  
				;(actually, usually use some other
				;system switch
DEFINE STANFO <IFN STANSW,>	;code for stanford only
DEFINE NOSTANFO <IFE STANSW,>	;code not allowed at stanford ever
DEFINE EXPO <IFN EXPORT, >	;code for export only (BEING PHASED OUT)
DEFINE NOEXPO <IFE EXPORT, >	;code for Stanford only (BEING PHASED OUT)
DEFINE CMU <IFN CMUSW,>		;CODE ONLY FOR CMU
DEFINE NOCMU <IFE CMUSW,>	  ;CODE NEVER FOR CMU
DEFINE IMSSS <IFN IMSSSW,>	;IMSSS version of TENEX-SAIL
DEFINE NOIMSSS <IFE IMSSSW,>
DEFINE PARC <IFN PARCSW,>	;CODE ONLY FOR PARC
DEFINE NOPARC <IFE PARCSW,>	;NEVER FOR PARC
DEFINE SRIAI <IFN SRIAISW,>	;CODE ONLY FOR SRI-AI
DEFINE NOSRIAI <IFE SRIAISW,>	;NEVER 
DEFINE JPL <IFN JPLSW,>		;AT JPL
DEFINE NOJPL <IFE JPLSW,>	;NOT AT JPL
DEFINE GLOB <IFN GLOBSW, >	;since global compiler (GLOBC) can service
DEFINE NOGLOB <IFE GLOBSW, >	; non-global code, GLOBC is different
DEFINE GLOC <IFN GLOBC, >	; from GLOB (global model)
DEFINE NOGLOC <IFE GLOBC, >
DEFINE UP <IFN UPPER,>		;upper segment code (only used in runtime)
DEFINE NOUP <IFE UPPER,>	;not
DEFINE LOW <IFN LOWER,>		;lower bootstrap for 2 seg thing (ditto)
DEFINE NOLOW <IFE LOWER,>	;not
DEFINE LEP <IFN LEAPSW,>	;this compiler understands LEAP
DEFINE NOLEP <IFE LEAPSW,>	;doesn't (applies to runtime too)
DEFINE REN <IFN RENSW,>		;Re-entrant output (comp), runtimes (runtim)
DEFINE NOREN <IFE RENSW,>
DEFINE RENC <IFN RENCSW,>	;The compiler itself is reentrant
DEFINE NORENC <IFE RENCSW,>	;The compiler itself is not reentrant
DEFINE HACK <IFN HACKSW,>	;TEMPORARILY VERSION FOR STANFORD
DEFINE NOHACK<IFE HACKSW,>	; WILL DISAPPEAR NEXT SAISG
DEFINE TENX<IFN TENXSW,>	;FOR TENEX SYSTEMS
DEFINE NOTENX<IFE TENXSW,>	;NOT

; ** CONDITIONAL SETTINGS **

DEFINE STSW (V,VL) <IFNDEF V,<?V←←VL>>


STSW (STANSW,1);NOT USUALLY EXPORT VERSION
STSW (HACKSW,STANSW) ;ONLY AT STANFORD
STSW (TENXSW,0); NOT USUSALLY AT TENEX
STSW (CMUSW,0); NOT USUALLY AT CMU 
STSW (IMSSSW,0); NOT USUALLY AT IMSSS
STSW (PARCSW,0); NOT USUALLY AT PARC
STSW (SRIAISW,0); NOT USUALLY AT SRIAI
STSW (JPLSW,0);	NOT USUALLY AT JPL
STSW (RENCSW,0)	;NOT USUALLY A REENTRANT COMPILER
STSW (DECSW,1); USUALLY DEC 10-50 BASED SYSTEM
STSW (HEDSYM,0)		;USUALLY NOT A USER-TABLE SYMBOL GENERATOR
NOCMU <
STSW(GLOBSW,0)		;USUALLY NOT A GLOBAL SEGMENT BEING MADE
>;NOCMU

NOSTANFO <
?EXPORT ←← 1 	; TAKE CARE OF OBSOLETE SWITCH
STSW (SIXSW,0)
>;NOSTANFO
STANFO <
?EXPORT ←← 0
STSW (SIXSW,1)
>;STANFO	

CMU < ;**** EXTRA SWITCHES FOR CMU ******
DEFINE GGAS <IFN GASSW,>	;cmu version of global segment
DEFINE NOGGAS <IFE GASSW,>	;inverse
DEFINE GGGON < GLOBSW←←GASSW>	;
DEFINE GGGOFF < GLOBSW ←←0>	;USED TO SELECT SOME OF SU-AI GLOB STUFF
STSW(GASSW,0)			;NOT USUALLY CMU GLOBAL
↑↑GLOBSW ←← 0			;CANNOT DEFINE IT (USING STSW)
				;    WITH ? SINCE GGGON REDEFINES
DEFINE GLOB < IFNDEF GLOBSW,<GLOBSW←←0>
		IFN  GLOBSW, >
DEFINE NOGLOB < IFNDEF GLOBSW,<GLOBSW←←0>
		IFE   GLOBSW,>
>;CMU

IMSSS <;DEFAULT SETTINGS AT IMSSS
?TENXSW←←1			;TENEX AT IMSSS
?SIXSW←←1			;USE SIXBIT PPN'S FOR LOADER AT IMSSS
>;IMSSS

PARC <
?TENXSW←←1			;TENEX AT PARC
?SIXSW←←0
>;PARC

JPL <
?TENXSW←←1
?SIXSW←←0
>;JPL

SRIAI <
?TENXSW←←1			
?SIXSW←←0
?RUBCHAR←←"A"-100		;CONTROL-A FOR CHARACTER DELETE
?DELLINE←←"X"-100		;CONTROL-X FOR LINE DELETE
>;SRIAI

TENX <;DEFAULT SETTINGS AT TENEX
?RENCSW←←1			;WANT A RE-ENTRANT COMPILER
?RENSW←←1			;WANT A RE-ENTRANT RUNTIME
?DECSW←←0			;NOT A DEC SYSTEM
?EXPORT←←1			;AVOID STANFORD FEATURES
?STANSW←←0			;IN FACT, EXPLICITLY NOT STANFORD
?GLOBSW←←0			;NOT USUALLY GLOBAL FOR TENEX
?GLOBC←←0			;
STSW(LOADVR,54)			;TENEX SITES SEEM TO HAVE V. 54
>;TENX


;; %BC% KVL 1-6-74	ADD BAILD SWITCH
DEFINE BAIL <IFN BAISW,>
DEFINE NOBAIL <IFE BAISW,>
STSW (BAISW,0)		;USUALLY OFF
;; %BC%
COMMENT ⊗ THE FILSPC STUFF -- OLDER HISTORY ⊗


COMMENT ⊗
VERSION 17(3) 8-19-73 BY RHT DECUS!!!
VERSION 17(2) 7-26-73 
VERSION 16-2(11) 7-26-73 BY JRL VERSION 17
VERSION 16-2(10) 7-26-73 BY jrl RECONFIGURE FOR VERSION 17
VERSION 16-2(9) 1-8-73 BY JRL LIB NAMES NOW LIBSA5,HLBSA5
VERSION 16-2(8) 12-2-72 BY RHT CONFIGURE FOR SAISG5, ETC
VERSION 16-2(7) 9-21-72 BY JRL RECONFIGURE FOR SAIL
VERSION 16-2(6) 8-29-72 BY RHT CONFIGURE FOR NSAIL (PROCESSES, EVENTS, ETC.)
VERSION 16-2(5) 7-2-72 BY RHT PUT UP VERSION 16
VERSION 16-2(4) 6-25-72 BY DCS SAISG4 UPDATES V16 FEATURES
VERSION 16-2(3) 6-24-72 BY DCS BUG #HX# PARAM PROCESSOR NAME, LIBRARIES
VERSION 16-2(2) 5-13-72 BY DCS INSTALL VERSION 16
VERSION 15-2(1) 12-2-71 BY DCS INSTALL VERSION NUMBER

⊗;
; FILSPC FILES

IFNDEF TSTSEG,<TSTSEG←←0>
NOTENX <
IFN TSTSEG,<
DEFINE FILXXX <SIXBIT /SAISGT/>
DEFINE SLOFIL <SIXBIT /SAILWT/>
DEFINE SGDEVC <SIXBIT /DSK/>
STANFO <
DEFINE SGPPNN <SIXBIT /  SAIL/>
>;STANFO
NOSTAN <
DEFINE SGPPPN <0>
>;NOSTAN
?LOCSYM←←1
?NOPROT←←1
>
IFNDEF FILXXX,<DEFINE FILXXX <SIXBIT /SAISG7/>>
;SAILOW FOR PROCESSOR SAIL, EXTENSION SAI
;SAILOX  "	      OSAIL,   "      OSA
;SAILOY  "	      NSAIL,   "      NSA
IFNDEF SLOFIL,<DEFINE SLOFIL <SIXBIT /SAILOW/>>;PRODUCTION SAIL
IFNDEF SGDEVC,<DEFINE SGDEVC <SIXBIT /SYS/>>
IFNDEF SGPPNN,<DEFINE SGPPNN <0>>
IFNDEF LOCSYM,<?LOCSYM←←0>;DON'T WANT LOCAL SEGMENT SYMBOLS
IFNDEF NOPROT,<?NOPROT←←0>	;DON'T WANT SEGMENT PROTECT IF NOT GLOBAL

DEFINE PROCSR <ASCIZ /SAIL: />	;FOR PRINTOUT OF PROCESSOR
DEFINE RPGFIL <SIXBIT /QQSAIL/> ;FOR COMPIL PURPOSES
DEFINE DEFEXT <'SAI'>		;DEFAULT EXTENSION

?LIBLEN←←=10				;LENGTH OF FOLLOWING STRINGS
DEFINE LIBLOW <ASCIZ /SYS:LIBSA7/>	;REQUIRED LIBRARIES
DEFINE LIBHI  <ASCIZ /SYS:HLBSA7/>	; (HISEG VERSION)

DEFINE OPDEV   <SIXBIT /SYS/>		;DEVICE FOR OPCODE FILE
DEFINE OPNAME  <SIXBIT /2OPS2/>		;NAME OF SAME (EXTEN ALWAYS OPS)
DEFINE OPPPN   <0>			;WHERE IT'S AT

GLOB <
DEFINE FILXXX <SIXBIT /GLBSG7/>
DEFINE SLOFIL <SIXBIT /GLBLOW/>
DEFINE SGDEVC,<SIXBIT /SYS/>
DEFINE SGPPNN,<0>
?NOPROT←←1
?LOCSYM←←1
>;GLOB

CMU <
GGAS <	;OH WELL
DEFINE SGDEVC <SIXBIT/DSK/>
DEFINE FILXXX <SIXBIT/CONSEG/>
DEFINE SGPPNN <XWD 1305,60410>	
		;KLUDGE - HACK - A700CR00, WHEREON THE CONTROLLER LIVES.
>;GGAS
>;CMU
>;NOTENX

TENX <
IFN TSTSEG,<
IFNDEF FILXXX,<DEFINE FILXXX <ASCIZ /<SAIL>T-SAISGT.SAV/>>
IFNDEF SLOFIL,<DEFINE SLOFIL <SIXBIT /SAILWT/>>
?LOCSYM←←1
?NOPROT←←1
IFNDEF LIBLOW,<DEFINE LIBLOW <ASCIZ /LIBSAT.REL/>>
?LIBLEN←←=10
>;IFN TSTSEG
IFE TSTSEG,<
IFNDEF FILXXX,<DEFINE FILXXX <ASCIZ /<SAIL>T-2-SAISG7.SAV/>>
IFNDEF SLOFIL,<DEFINE SLOFIL <SIXBIT /LOWTSA/>>
IFNDEF SLOLOD,<DEFINE SLOLOD <ASCIZ/SYS:LOWTSA,/>>	;FOR INTERFACE TO LOADER
?LOCSYM←←0
?NOPROT←←0
IFNDEF LIBLOW,<DEFINE LIBLOW <ASCIZ /<SAIL>LIBSA7.REL/>>
IFNDEF LIBHI,<DEFINE LIBHI <ASCIZ /<SAIL>HLBSA7.REL/>>
IMSSS<
IFNDEF SDTLOD,<DEFINE SDTLOD <ASCIZ/,SDDTRL[S,AIL]/>>
>;IMSSS
?LIBLEN←←=16
>;IFE TSTSEG
?SEGPAG←←640				;PAGE WHERE THE SEGMENT STARTS
?STARTPAGE←←610				;PAGE WHERE CHANNEL BUFFERS BEGIN
?JFNSIZE←←20				;NUMBER OF CHANNELS ALLOWED
IFNDEF RUNLOD,<DEFINE RUNLOD <=18
			      POINT 7,[ASCIZ/<SUBSYS>LOADER.SAV/],-1 >>
IFNDEF BKTFIL,<DEFINE BKTFIL <ASCIZ /<SAIL>BKTBL.BKT/>>
IFNDEF UDTFIL,<DEFINE UDTFIL <ASCIZ /<SAIL>UDDT.SAV/>>
IFNDEF OPFILE,<DEFINE OPFILE <ASCIZ /<SAIL>3OPS3.OPS/>>
>;TENX
; NARRATIVE FILSPC ACCOUNTS

STANFO <  ; ACTUALLY, NOT KEPT UP LATELY
COMMENT ⊗
HISTORY OF SAIL SYSTEMS
3-1-71   VERSION 'SG1',,10
 NEW SAIL SYSTEM UP, COMPILER AND RUNTIME
 FEATURES:
   NEW SEGMENT SCHEME ELIMINATES SAISYM GARBAGE, ALLOWS EXPO SHARED
	SEGMENTS, USE OF LATEST DEC LOADER.
   NEW RAID WENT UP AT SAME TIME.
   NEW LOADER (.052 MODIFIED) AT SAME TIME; WORKS AS LISP LOADER.
   NEW DDT?
   I/O ERROR ENABLE BUSINESS; BETTER SUBSTRING STUFF;
	PUNCTUATION ERROR ENABLE IN LOOKUP, ETC.
   NONSTD BUFFER SIZES
   USERCON
   FREITM
   GC CHANGE (WORKS WITH XPAND 0)
   CVFIL, CVOS BETTER.
3-12-71  GLOBAL SEGMENT GLBLOW,GLBSG2 UP
   FIXED PTYALL BUG, WHICH CAUSED MESSAGE PROCEDURES TO BLOW
3-15-71 GLOBAL SEGMENT GLBLOW,GLBSG3 UP
   PTYALL FIXES SOME MORE -- GLUB.
3-21-71  GLBLOW, GLBSG4 CREATED, TESTED
    REQUIRE -1 NEW!ITEMS (GLOBAL OR NOT) INHIBITS LOCAL MODEL
3-21-71 FILES FOR RUNTIMES, GREATLY MODIFIED, TRANSFERRED
    FROM T,AIL WHERE THEY HAD BEEN SUCCESSFULLY TESTED IN
    ALL CONFIGURATIONS I COULD THINK OF -- FACILITATE MUCH
    MORE RAPID LIBRARY CREATION (THERE IS NOW ONLY 1 SCISS).
6-22-71  MESPRO CHANGED TO ADD NEW FEATURE TO PUT!DATA.

7-16-71 VERSION 'SG2',,11  (version SG6 for global model)
 NEW SAIL SYSTEM, COMPILER AND RUNTIME
 FEATURES:
  CASE STATEMENT IMPROVEMENTS OUTLINED IN NEWMAN AND DOCS.UPD
  REQUIRE n VERSION IMPLEMENTED
  MYRIAD BUGS FIXED
  LEABOT AND FRLOC TABLES ELIMINATED FROM USER TABLE
  REQUIRE -1 NEW!ITEMS GIVES NO LOCAL MODEL ALLOCATION
  RETURN CODE CHANGED -- MORE EFFICIENT -- NOW A LOCAL STRING
    VARIABLE MAY BE RETURNED FROM A RECURSIVE STRING PROCEDURE.
  AOS PAT/SOS PAT STUFF REMOVED FROM GENERATED PROCEDURES.
  FREITM MOVED TO BE WITH OTHERS IN USER TABLE
  THE RES COUNTER SYSTEM (/K) INSTALLED (SEE DOCS.UPD ETC.)
7-21-71 VERSION GLBLOW,GLBSG7 UP
	MESSAGE PROCEDURE ROUTINE PUT!DATA(0,0,NAME) CHANGED TO REQUIRE
ALL JOBS ENTERED TO HAVE SAME VERSION NUMBER
10-20-71 VERSION GLBSG8 UP - RANDOM BUGS FIXED

5-13-72 VERSION 16 (16 runtime) OF SAIL UP FOR EXPERIMENTATION
 FEATURES:
  1. Various improvements
  2. New stack structure, up-level addressing, jumps out BY RHT
  3. Improved LEAP by JRL
  4. Improved macros by HJS
 SAISG3
6-25-72 VERSION 16 PUT UP AS STANDARD PROCESSOR,  NSAIL.  The files:
  NSAIL.DMP[1,3] is the compiler, ext. NSA (uses SAISG4).
  SAILOY.REL[1,3] is the low segment (always for NSAIL)
  SAISG4.SEG[1,3] is the segment
  LIBSA1, HLBSA1[1,3] are the libraries.
 Will go back to SAISG3 shortly.
7-3-72 VESRION 16 PUT UP AS STANDARD SAIL
  OLD SAIL (VERSION "15") BECOMES STANDARD PROCESSOR "OSAIL"
	EXTENSION .OSA , LOW SEGMENT IS SAILOX (PREV SAILOW)
	SAISG2.REL IS ITS UPPER
  NOW SAISG3.SEG IS THE UPPER, SAILOW.REL IS THE LOWER, LIBSA1, HLBSA1 
  ARE THE LIBRARIES.
10-22-72 NEWER, BETTER SAIL PUT UP.  SAISG4 IS THE SEGMENT

12-7-72 VERSION 16 (REVISED) PUT UP AS STANDARD PROCESSOR
 FEATURES:
  1. miscellaneous bugs fixed
  2. More LEAP modifications by JRL
  3. CLEANUPs to blocks
  4. User initialization happens as first executable statement.

 SAISG5.SEG is the segment.  LIBSA5.REL is the library.

7-25-73 VERSION 17 PUT UP AS STANDARD PROCESSOR (DECUS RELEASE??)
 FEATURES
  1. bug fixes
  2. macro changes
  3. process changes
 SAISG6.SEG is the segment. LIBSA6.REL, the library.
 GLBSG6.SEG is the global segment.

8-19-73 TRANSFERRED FILES OVER TO X,AIL FOR DECUS RELEASE
⊗
>;STANFO


;LISTING CONTROL MACROS & THE LIKE

;VARIOUS HANDY MACRO DEFINITIONS TO TRY TO MAKE THE CODE
;SOMEWHAT MORE READABLE.

II←←1
FOR @' JJ IN (HEAD,SAIL,PARSE,PDEFS,PRODS,SUBRS,SMTB,SYM,GEN,ARRAY) <
?..'JJ←←II
II←←II⊗1
>
FOR @' JJ IN (EXPRS,STATS,LEAP,TOTAL,COMSER,GOGOL,STRSER,IOSER,LEPRUN,MESPRO,WRDGET) <
?..'JJ←←II
II←←II⊗1
>
IFDEF SETLST,<SETLST>

IFNDEF ..LIST,<
..LIST←←0
FOR @' JJ IN (HEAD,SAIL,PARSE,SYM,GEN,ARRAY,EXPRS,STATS,LEAP,TOTAL,COMSER) <
?..LIST←←..LIST!..'JJ
>
FOR @' JJ IN (GOGOL,STRSER,IOSER,LEPRUN,MESPRO,WRDGET) <
?..LIST←←..LIST!..'JJ
>>
IFDEF SETLS2,<
	SETLS2
>
DEFINE LSTON ' (JJ) <
	XLIST
IFN ..LIST & ..'JJ,<
	LIST>
>
	LSTON	(HEAD)

DEFINE DSCR <COMMENT ⊗ > ; FOR DIRECTORY MAKER

DEFINE GEN <IFE .NOGEN,<LALL>>
DEFINE NOGEN <XALL>
?.NOGEN←←1	;DON'T EXPAND MACROS AT ALL AFTER FIRST NOGEN
	NOGEN

DEFINE IFNB (X) <IFDIF <><X>,>
DEFINE IFB (X) <IFIDN <><X>,>


DSCR  STORAGE MANAGEMENT MACROS
⊗

DSCR  HERE
CAL MACRO
PAR ROUTINE NAME
DES For runtime routine vector.  If this is a library or one-segment
 run, this is equivalent to placing a label "HERE".  Otherwise, the
 label is placed on a JRST instruction in a vector of JRST's in the
 upper segment.  The  JRST is to "HERE".  This allows the code for
 runtimes to be changed without forcing everyone to forsake their
 SAIL-compiled core images.
⊗

DEFINE HERE(X) <
UP <
	FQQQQ ←← .
	USE DSPCH	;SO THAT THE LABELS HAVE THE SAME ADDRESS
			;FROM ONE ASSEMBLY TO ANOTHE.
↑↑ X :	JRST	FQQQQ
	USE
>;UP
NOUP <
↑↑ X :			;IF NOT MAKING AN UPPER SEGMENT, DOES NOT MATTER.
>;NOUP
>


DEFINE HEREFK (X,XFAKE) <
UP<
↑↑ XFAKE:		; A FAKE LABEL (FELLOW WILL HAVE REAL THING IN SPARES
>;UP
NOUP <
HERE(X)			;ONLY MATTERS IF MAKING A SEGMENT
>;NOUP
>

DSCR SETCOR (SIZE,FIRST,LAST)
CAL MACRO
PAR SIZE is CORGET size desired
 FIRST (optional) is vbl which will point to first word
 LAST (optional) is vbl which will point to first word after block
RES CORGET called, B put into FIRST, LAST computed
ERR if not enough core, complains
DES used in ALLOC (SAILOR sequence)
SEE ALLOC
⊗

DEFINE SETCOR (SIZE,FIRST,LAST) <
	MOVE	C,SIZE
	PUSHJ	P,CORGET
	ERR	<CAN'T GET CORE FOR FIRST ALLOCATION>
	IFDIF <FIRST><>, <MOVEM	B,FIRST>
	IFDIF <LAST><>,<
		ADD	C,B
		MOVEM	C,LAST
>>

DSCR DATA, ZERODATA, TABLEDATA,--etc.
CAL MACRO
PAR One argument, a description
RES For ZERODATA, the ZVBLS PC is switched to for the data.  For others,
 the VBLS PC.  A check is made to ensure that the appropriate area is
 big enough for the new data.
DES This allows data to be concentrated in one area (for reentrancy
 consideration, one-instruction CLEAR operations, etc.), but to
 be defined locally.  Some special purpose programs can examine the
 CREF listing file to print summaries, sorted cross-references, etc.
⊗

DEFINE DATA (MSG) <
	USE	VBLS
	IFGE	.-DBASE-DSIZE,<#DATERR	;DATA AREA TOO SMALL
>>

DEFINE TABLEDATA (MSG) <
	ZERODATA ()
>

DEFINE TABCONDATA (MSG) <
	DATA ( )
>

DEFINE ZERODATA (MSG) <
	USE	ZVBLS
	IFGE	.-ZBASE-ZSIZE,<#DATERR	;ZEROED DATA AREA TOO SMALL
>>

DEFINE BITDATA (MSG) <	USE>

DEFINE BITDDATA (MSG) <	USE>

DEFINE BIT2DATA (MSG) <	USE>

DEFINE BITD2DATA (MSG) < USE>

DEFINE ACDATA (MSG) <	USE>

DEFINE AC2DATA (MSG) <	USE>

DEFINE ENDDATA <
IFDEF ZBASE, <
	DATA ()		;CHECK
	ZERODATA ()		;CHECK
	USE
>>




COMMENT ⊗

DSCR LEVPOINT
DES CHEAP MACRO TO GENERATE POINTERS TO DISPLAY LEVEL FIELD OF WORDS
⊗

DEFINE LEVPOINT(AD)< POINT DLFLDL,AD,35-LLFLDL>

;;%  % CMU STYLE TRAP CALL MACRO -- SHOULD REALLY BE TURNED INTO ROUTINE CALL
DEFINE TRPCAL (P1,P2,P3,P4,ADR) <
BEGIN
	SKIPN	ADR
	 JRST 	 NOTRP
CMU <  GGGON	;
>;CMU
GLOB <
	PUSH	P,USER
	MOVE	USER,GOGTAB	;IT MAY HAVE BEEN GLUSER
>;GLOB
	PUSH	P,TEMP
	PUSH	P,UUO1(USER)
	MOVEI	TEMP,.TRACS
	BLT	TEMP,.TRACS+11
	MOVE	TEMP,-1(P)
	PUSH	P,P1
	PUSH	P,P2
	PUSH	P,P3
	PUSH	P,P4
	PUSHJ	P,@ADR
	MOVSI	TEMP,.TRACS
	BLT	TEMP,11
	POP	P,UUO1(USER)
	POP	P,TEMP
GLOB <
	POP	P,USER		;GET IT BACK
>;GLOB
CMU <   GGGOFF			;DELSELECT GLOBAL STUFF
>;CMU
NOTRP:
BEND
>;END TRPCAL DEF
; MACHINE-EXTENDING MACROS (SOME USEFUL CONSTANT, STORAGE/STORAGE MANIPULATORS)

DSCR MOVEWI, MOVEW, MOVE6, MOVEI7, LOAD6, LOADI7
CAL MACRO
DES Provide extended "instructions" for data movement
 MOVEWI(I,J) moves J (immed) to I via TEMP
 MOVEW(I,J)  moves J to I via TEMP
 MOVE6(I,J)  moves SIXBIT /J/ to I via TEMP
 MOVEI7(I,J) moves addr of ASCIZ /J/ to I via TEMP
 LOAD6 (I,J) moves SIXBIT /J/ to AC I
 LOADI7(I,J) moves addr of ASCIS /J/ to AC I
SID TEMP -- sometimes changed
⊗

DEFINE MOVEWI (I,J) <
		MOVEI TEMP,J
		MOVEM TEMP,I
>

DEFINE MOVEW (I,J) <
		MOVE	TEMP,J
		MOVEM	TEMP,I
>

DEFINE MOVE6 (I,J) <
		MOVE	TEMP,[SIXBIT /J/]
		MOVEM	TEMP,I
>

DEFINE MOVEI7 (I,J) <
		MOVEI	TEMP,[ASCIZ /J/]
		MOVEM	TEMP,I
>

DEFINE LOAD6 (I,J) <
		MOVE	I,[SIXBIT /J/]
>

DEFINE LOADI7 (I,J) <
		MOVEI	I,[ASCIZ /J/]
>

DSCR SAVACS, RESTACS (L)
CAL MACRO
PAR a list like <A,C,LPSA>
RES specified AC's pushed on (popped from) P-stack
⊗
DEFINE SAVACS (L) <
 FOR II IN  L ,<
	PUSH	P,II
>>
DEFINE RESTACS (L) <
FOR II  IN  L, <
	POP	P,II
>>

DSCR CALL6(I,J)
CAL MACRO
PAR I is AC# if J is present, else see J
 J is symbolic value for a system CALL
RES does CALLI AC,U&INDEX 
 AC defaulted to 0
⊗

NOTENX <
NOSTANFO <
DEFINE CALL6 ' (I,J) <
	IFDIF <><J>,<
		IFDIF <><I>,<CALLI I,U'J;>  CALLI U'J
>
	IFIDN <><J>,<
		CALLI	U'I
>>
>;NOSTANFO

STANFO <
DEFINE CALL6 ' (I,J) <
	IFDIF <><J>,<
		IFDIF <><I>,<J I,;> J
>
	IFIDN <><J>,<
		I
>>
>;STANFO

NOSTANFO <
DEFINE CX ' (Y,Z) <
?U'Y←←Z
>

	CX RESET,0	;0 RESET IO
	CX DDTIN,1	;1 EXT-GET DDT CHAR.
	CX SETDDT,2	;2 SETDDT LOC IN PROTECTED JOB DATA
	CX DDTOUT,3	;3 EXT:SEND DDT CHAR.
	CX DEVCHR,4	;4 DEVICE CHARACTISTICS
	CX DDTGT,5	;5 GET DDT MODE
	CX GETCHR,6	;6 DEVICE CHAR.(DIFF. NAME)
	CX DDTRL,7	;7 RELEASE DDT MODE
	CX WAIT,10	;10 WAIT TILL DEVICE INACTIVE
	CX CORE,11	;11 CORE UUO
	CX EXIT,12	;12 EXIT
	CX UTPCLR,13	;13 CLEAR DEC TAPE DIRECTORY 
	CX DATE,14	;14 GET DATE
	CX APRENB,16	;16 ENABLE APR FOR TRAPPING
	CX SWITCH,17	;20 RETURN DATA SWITCHES
	CX REASSIGN,21	;21 REASSIGN DEVICE TO ANOTHER JOB
	CX TIMER,22	;22 RETURN JIFFY CLOCK TIME
	CX MSTIME,23	;23 RETURN TIME OF DAY IN MS
	CX GETPPN,24	;24 RETURN PROJECT-PROGRAMMER NUMBER
	CX TRPSET,25	;25 SET PI TRAP LOC, AND USER IO
	CX TRPJEN,26	;26 DISMISS INTERRUPT TO EXEC MODE
	CX RUNTIM,27	;27 RETURN TOTAL JOB RUNNING TIME
	CX PJOB,30	;30 RETURN JOB NUMBER
	CX SLEEP,31	;31 SLEEP FOR N SECONDS, THEN RETURN TO USER
	CX SETPOV,32	;32 SET PUSH DOWN OVERFLOW TRAP
				;(FOR COMPATIBILITY ONLY)
	CX PEEK,33	;33 PEEK INTO SYSTEM CORE.		;JS
	CX GETLIN,34	;34 GET NAME OF TTY
	CX RUN,35	;35 RUN COMMAND
	CX SETUWP,36	;36 SET USER WRITE PROTECT
	CX REMAP,37	;37 REDO CORE MAP
	CX GETSEG,40	;40 GET SEGMENT
	CX GETTAB,41	;41 GETTAB ILLEGAL AT STANFORD.
>;NOSTANFO
>;NOTENX


;  TELETYPE COMMUNICATION MACROS

DEFINE OP1 &(OPR,MS,ACC)  <
	IFIDN <ACC><>, <II←←0>
	IFDIF <ACC><>, <II←←ACC>
	OPR&. II,[ASCIZ /MS/]
>

DSCR IOERR (STR)
CAL MACRO
PAR ASCII string to be printed
RES calls IOERR. UUO to print message, either restart
 compiler or EXIT
⊗

DSCR ERR (STR,CODE,ROUT)
CAL MACRO -- calls ERR. UUO
PAR STR ASCII string to be printed
 CODE determines how UUO functions
 ROUT is address or literal to jump to if ERR continues
RES If SAIL is on DPY, displays input line
 Prints STR
 CODE%2 determines what else to print -- if CODE is:
  0-1:  Print nothing more
  2-3:  Ident name for Semantics in LPSA (SAIL only)
  4-5:  Ident name for Semantics in UUO instr (SAIL only)
  6-7:  Value of AC in AC field of instr preceding UUO
 10-11: The UUO in octal
 12-13: Value of AC field of instr preceding that indicated
        by UUO1(GOGTAB)

 If CODE is even, don't allow continuation -- otherwise
  allow continuation in manner described by error message.
 If ROUT is present, jump to it -- else continue in line
⊗
FOR OP  IN  (ERR,IOERR) <
DEFINE OP (MSG,AC,ADDR) <
	IFIDN	<ADDR><>,<OP1 (OP,<MSG>,AC)>
	IFDIF <ADDR><>,<JRST	[OP1 (OP,<MSG>,AC)
			   JRST	ADDR ]>
>>

DSCR CORERR
CAL MACR
PAR	message
RES	Types the message, then exits the program 
SID none
⊗
DEFINE CORERR(MSG) < JRST [	PUUO	3,[ASCIZ /MSG
/]
NOTENX <
				CALL6	EXIT
>;NOTENX
TENX <
				JSYS	HALTF
>;TENX
							]>

DSCR PRINT, TERPRI (STR)
CAL MACRO -- calls prin.. uuo.  
PAR Ascii message
RES Types string -- types CRLF after if TERPRI -- ERRPRI sends to log file if
user is enabled for that.
SID none
⊗
DEFINE ERRPRI (X) <
	PUSH	P,A
	MOVEI	A,[ASCIZ /X
/]
	PUSHJ	P,PRINT.
	POP	P,A
>

DEFINE PRINT (X) <
	PUUO 3,[ASCIZ /X/]
>

DEFINE TERPRI (X) <
	PUUO	3,[ASCIZ /X
/]>

DEFINE SPRINT(X) <	;SAFE PRINT, BEFORE UUO SET UP
	TTCALL 	3,[ASCIZ /X/]
>

;  INPUT/OUTPUT AIDS

DSCR MAKCDB (CHN, NAM, MODE, I, O)
CAL MACRO
PAR CHN channel number
 NAM Prefix for symbols defined
 MODE data mode
 I,O # input, # output buffers
RES generates a table to specify all (most?) data about
 a file (Source, Rel, Command, etc.), instructions
 tailored for this channel -- it takes the form: ⊗

DEFINE MAKCDB &  (CHN,NAM,MODD,I,O)  <
NAM&CDB:
NAM&MOD: MODD			;DATA MODE
NAM&DEV: 0			;DEVICE NAME IN SIXBIT
NAM&HED:
	IFN O,<XWD NAM&HDR,0;> NAM&HDR  ;BLOCK HEADER POINTER
NAM&HDR: 0			;I/O HEADER BLOCK
NAM&PNT: 0			;I/O BYTE POINTER
NAM&CNT: 0			;I/O CHAR COUNT
↑NAM&FIL: 0			;I/O FILE NAME
↑NAM&EXT: 0			;I/O EXTENSION
NAM&OP:	OPEN	CHN,NAM&CDB	;OPEN INSTRUCTION
NAM&NT:
	IFN I,<LOOKUP CHN,NAME;> ENTER CHN,NAME
NAM&SPC:
	IFN O,<OUTBUF CHN,O>
IFE O,<
NOSTANFO <
	 IFIDN <NAM> <SRC>, <
		PUSHJ P,[MOVEI TEMP,.+1 ; PTR TO DESCRIPTOR, CALL UINBF ROUTINE
			 JRST	UINBF] ;>INBUF CHN,I
>;NOSTANFO
STANFO <
		    UINBF CHN,.+1
>;STANFO
>;IFE O
NAM&BFS: IFN O,<O;>	I		;# OF BUFFERS
	202	;MAKE BIGGER BUFFERS THAN NORMAL (INPUT ONLY)
>

DSCR CHKCHN, TSTERR, TSTEOF
CAL MACRO
PAR First argument is channel # (AC containing same for CHKCHN)
 2d argument is routine name for CHKCHN, address for TSTEOF
RES CHKCHN makes sure channel # in AC is legal
  prints error message using routine name, if not legal
 TSTERR does an error STATZ
 TSTEOF jumps to Address if EOF is present on the channel
⊗
DEFINE CHKCHN (AA,ROUTIN) & <
		TRZE	AA,777760	;ZERO BITS AND TEST VALID
		ERR <ROUTIN&: INVALID CHANNEL NUMBER>
>

DEFINE TSTERR (CHAN) <
		STATZ CHAN,740000 ;ANY ERRORS?
>

DEFINE TSTEOF (CHAN,EOFADD) <
		STATZ CHAN,20000  ;END OF FILE?
		JRST EOFADD	  ; YES
>

; RANDOM OTHER MACROS

DEFINE SETNIT <
	MOVE	TEMP,[PUSHJ P,%UUOLNK]	;MAKE SURE WE CAN DO UUOS
	MOVEM	TEMP,41
	MOVE	P,ALLPDP	;AND PUSHJ'S
>

DSCR SETPOV(AC,STR)
CAL MACRO
PAR AC REPRESENTING PUSH-DOWN POINTER
STR REPRESENTING SOME SUGGESTIONS FOR ACTION WHEN THIS PTR OVERFLOWS
RES POVTAB has one entry for each AC.  the string pointer (0 if none)
 is put into this entry.  If a PDP in this AC overflows,  POVTRP, which
 is enabled in SALNIT for PDL-OV, prints the string as a standard fatal
 error message.  POVTRP is in  COMSER.
SEE POVTRP
⊗

DEFINE SETPOV (AC,STR) <
 IFIDN <STR><><MOVEI TEMP,0;>MOVEI TEMP,[ASCIZ ?STR?] ;GET VALUE
 II←←(AC+17)&17			;BETWEEN 0 AND 17
 JJ←←II-(2*(II/2))		;ODD OR EVEN
 IFE JJ,<HRLM TEMP,POVTAB+(II/2); EVEN-- LEFT> HRRM TEMP,POVTAB+(II/2)
>;SETPOV
;TBITS DEFINITIONS

DEFINE BIT(NAME,BITT) <IFDIF <NAME><SPARE>,<?NAME←←BITT>>
DEFINE DEFTBS <
	BIT	(RES,400000)	;RESERVED WORD
	BIT	(CNST,200000)	;CONSTANT ENTRY
	BIT	(SPARE,100000)	;****
	BIT	(INTRNL,40000)	;INTERNAL SYMBOL (SYMBOL EXPORTED)
	BIT	(EXTRNL,20000)	;EXTERNAL SYMBOL (STORAGE FOUND ELSEWHERE)
	BIT	(MPBIND,10000)	;MATCHING PROCEDURE OR BINDING ITEMVAR
	BIT	(VALUE,4000)	;FORMAL PARAMETER CALL BY VALUE
	BIT	(REFRNC,2000)	;FORMAL PARAMETER CALL BY REFERENCE
	BIT	(CONOK,1000)	;OK TO CALL INTRINSIC WITH CONST ARGS AT COMPTIME
	BIT	(SIMPLE,400)	;FOR DISPLAY SYSTEMS ONLY
	BIT	(MESSAGE,200)	;A MESSAGE PROCEDURE !!!!!(STANFORD ONLY).
	BIT	(OWN,100)	;OWN VARIABLE ?
	BIT	(ANYTYP,40)	;ANYTYPED VARIABLE (USED IN PROCEDURE CALLS)
	BIT	(SAFE,20)	;SAFE -- FOR ARRAYS AND SUCH.
	BIT	(DEFINE,10)	;DEFINED MACRO IDENTIFIER
	BIT	(RECURS,4)	;THIS ROUTINE IS REENTRANT
	BIT	(BILTIN,2)	;IF ON IN TBITS, DON'T SAVE AC'S ON CALL.
	BIT	(SBSCRP,1)	;SUBSCRIPED VARIABLE (ARRAY)

;RIGHT HALF BITS -- TBITS WORD.

	BIT	(INPROG,400000)	;PROCEDURE BEING DEFINED, KEEP FIXUP CHAIN
	BIT	(GLOBL,200000)	;GLOBAL LEAP VARIABLE
	BIT	(FORTRAN,100000);FORTRAN PROCEDURE (EXTERNAL)
	BIT	(FORWRD,40000)	;FORWARD PROCEDURE OR LABEL
	BIT	(PROCED,20000)	;PROCEDURE
	BIT	(SHORT,10000)	;SHORT INTEGER OR SHORT REAL
	BIT	(ITMVAR,4000)	;LEAP ITEMVAR
	BIT	(PNTVAR,2000)	;POINTER VARIABLE ?? (NOT IMPLEMENTED YET)
	BIT	(BOOLEAN,1000)	;BOOLEAN VARIABLE ?? (SAME AS INTEGER FOR NOW
				; SEE TYPSET IN FILE "GEN"
	BIT	(ITEM,400)	;LEAP ITEM
	BIT	(STRING,200)	;A FHQ STRING
	BIT	(LPARRAY,100)	;TYPE OF THIS ITEM IS ARRAY
	BIT	(SET,40)	;LEAP SET
	BIT	(LABEL,20)	;LABEL
	BIT	(LSTBIT,10)	; COMPLEX NUMBER ?? (NOT IMPLEMENTED)
	BIT	(DBLPRC,4)	; DOUBLE PRECISION NUMBER ?? (NOT IMPLEMENTED)
	BIT	(FLOTNG,2)	;REAL NUMBER
	BIT	(INTEGR,1)	;INTEGER NUMBER

;LEFT HALF OF %ERFLGS WORD -- STATE OF ERROR HANDLER

	BIT	(KEEP,1)	;DO NOT FLUSH TYPE AHEAD
	BIT	(QUIET,2)	;DO NOT PRINT MESSAGES
	BIT	(NUMBS,4)	;DO PRINT THE "CALLED FROM .." STUFF
	BIT	(LOGGIN,10)	;SEND MESSAGES TO LOG FILE
	BIT	(CONT,20)	;CONTINUABLE ERROR
	BIT	(AUTO,40)	;AUTOMATIC CONTINUATION MODE
	BIT	(LOGOPN,100)	;LOG FILE IS CURRENTLY OPEN
	BIT	(ERRNOW,200)	;WE ARE CURRENTLY IN THE MIDDLE OF AN ERR. UUO
	BIT	(MINUS,400)	;WE JUST SAW A MINUS!
	BIT	(MADEPT,1000)	;WE HAVE ALREADY MADE A BYTE POINTER FOR FAKETTY
	BIT	(BUFOPN,2000)	;HE HAVE A BUFFER FOR DUMP MODE LOGGING

>

DEFTBS		;DEFINE THE TBITS

?FNYNAM ←← RECURS 		;EXTERNAL+OWN+FNYNAM MEANS EXT REQ IS FOR
				; FOO$ INSTEAD OF FOO (CF SIN)

; VARIOUS DEFINITIONS OF USER UUO'S.
FLOAT←2B8	OPDEF	FLOAT	[2B8]
STANFO <
PDPFIX←<FIX>	OPDEF	PDPFIX	[FIX]
>;STANFO
FIX←3B8		OPDEF	FIX	[3B8]
IOERR.←4B8	OPDEF	IOERR.	[4B8]
ERR.←5B8	OPDEF	ERR.	[5B8]
SIXPNT←6B8	OPDEF	SIXPNT	[6B8]
ARERR←7B8	OPDEF	ARERR	[7B8]
DECPNT←11B8	OPDEF	DECPNT	[11B8]
OCTPNT←12B8	OPDEF	OCTPNT	[12B8]
TENX <
PUUO←15B8	OPDEF	PUUO	[15B8]
		OPDEF	TTCALL	[PUUO]
>;TENX
NOTENX <
PUUO←<TTYUUO>	OPDEF	PUUO	[TTYUUO]
		OPDEF	TTCALL	[TTYUUO]
>;NOTENX

JFOV←<JFCL 1,0>	OPDEF	JFOV	[JFCL 1,0]

STANFO <
DPYOUT←703B8	OPDEF	DPYOUT	[703B8]
DPYCLR←701B8	OPDEF	DPYCLR	[701B8]
UINBF←704B8	OPDEF 	UINBF	[704B8]

?SEGSIZUUO 	← 400022	;GET SIZE OF SECOND SEGMENT.
?CORE2UUO	← 400015	;GET SOME MORE SECOND SEGMENT.
?GLBAR		←← 1000		;CURRENT LENGTH OF GLOBAL MODEL AREA.
>;STANFO



SUBTTL	SAIL/GOGOL USER TABLE DESCRIPTION
DSCR USER DATA AREA TEMPLATE  
DES These values serve as indices for the run-time routines
  into the user's data table. The table is necessary to allow
  the routines to be re-entrant.  The table is allocated
  in the SAILOR sequence at startup time; many of its values
  (data area bounds, etc.) are placed in it at that time.
 One can force re-initialization of this and all other dynamic
  areas by setting GOGTAB to 0 before next CORGET.
SEE XX descriptions for all these goodies directly below
⊗

DEFINE XX (SYMBOL,SIZE,BACKUP) <
	?SYMBOL←←LOCAT
IFN HEDSYM,<
	ENTRY	SYMBOL			;FOR HEAD.REL SYMBOL FILE
>;N HEDSYM
	LOCAT←←LOCAT+1
	IFDIF<SIZE><>< LOCAT←←LOCAT+SIZE-1>
	IFDIF<BACKUP><>< LOCAT←←LOCAT-BACKUP>
>

LOCAT←←0		;MAKES SYMBOLS ABSOLUTE

; THESE VARIABLES WILL NOT BE RE-INITIALIZED BY THE INIT ROUTINE


; LINK TO STRING BLOCKS FOR STRING GARBAGE COLLECTOR

 XX CLER,,1

 XX UUO1	;TRADITIONAL LOC FOR GOGOL RETRN ADRS FOR ERROR MSGS.

;LOADER LINK CHAINS
 XX STRLNK
 XX SPLNK	;LINK END FOR SPACE ALLOCATION.
 XX SETLNK	;LINK END FOR SETS.
 XX SGROUT	;LINK UP STRING DSCRPTR GENERATOR ROUTINES HERE
 XX KNTLNK	;PROFILE COUNTER LINK END

;IMPORTANT STRING SPACE ENTRIES
 XX ST		;BOTTOM OF STRING SPACE
 XX STTOP	;TOP OF SAME
;;%  % DCS 12-3-73 New entries
 XX STLIST	;HEAD OF LIST OF STRING SPACES
 XX TOPBYTE	;NEXT FREE BYTE
 XX REMCHR	;-REMAINING FREE CHARS
;;#GI# DCS 2-5-72 REMOVE TOPSTR
 XX SGLIGN	;ON IF MUST BE ALIGNED TO FW BDRY (COMPILER ONLY).

; I/O CHANNEL POINTER TABLE
; EACH POINTS TO A "CHANNEL DATA BLOCK" FULL OF GOODIES
 XX CHANS,20

; I/O BREAK TABLES (FOR INPUT SCANNING ROUTINES)
 XX DSPTBL,=19,,	;BREAK CHAR DISPOSITION TABLE
 XX LINTBL,=19,,	;LINE NUMBER     "       "
 XX BRKTBL,=128,,	;CHARACTER BREAK TABLES
 XX BRKDUM		;EXTRA TO HELP STDBRK ALONG WITH DUMP MODE


 XX PDL		;IOWD SIZE,BASE  FOR SYSTEM PDL
 XX SPDL	;XWD SIZE,BASE FOR STRING PDL

STANFO <
XX  ZAPBEG,,1	;BEGINNING OF SECOND SEGMENT COPY OF STUFF.
		;FOR GLOBAL MODEL ONLY.
>;STANFO
CMU <
XX  ZAPBEG,,1	;JUST LIKE SU-AI
>; CMU

;LEAP   THINGS.

STANFO <
 XX CURMES		;CURRENT MESSAGE.
>;STANFO
 XX MAXITM		;CURRENT TOP ITEM NUMBER.
 XX OLDITM		;LINKED LIST OF OLD ITEMS (DUMP HEAP).
 XX INFOTAB		;POINTER TO "GOOD POINTER" BLOCK OF CORE.
 XX DATAB		;POINTER TO DATUM AREA.
 XX HASTAB		;POINTER TO THE LEAP HASH TABLE.
 XX FP1			;FREE STORAGE -- 1 WORD.
 XX FP2			;FREE STORAGE -- 2 WORDS.
 XX HASMSK		;THE MASK FOR HASHING INTO OUR HASH SPACE.
 XX HASHP		;FOR PNAMES. XWD NEXT FREE ARRAY ENTRY,ARRAY BASE.
 XX MKBP		;MAKE BREAK-POINT
 XX ERBP		;ERASE BREAK-POINT
 XX PUBP		;PUT BREAK-POINT (NOT IMPLEMENTED)
 XX REBP		;REMOVE BREAK-POINT.(NOT IMPLEMENTED)
 XX ITMTOP		;MAXIMUM PERMISSIBLE ITEM NUMBER.
 XX LEABOT		; PTR TO SEARCH CONTROL BLOCK FOR DERIVED SETS ERASE. 
 XX FRLOC		; PTR TO CURRENT ACTIVE FOREACH CONTROL BLOCK POINTER
 XX SCBCHN		; PTR TO CHAIN OF ABANDONED SCB'S
 XX FREITM	;NUMBER OF FREE ITEMS REMAINING

; MISC. ARRAY THINGS.
 XX ARYDIR	;FOR TELLING FOUR ARRAY ROUTINES WHICH END IS UP.
 XX ARYLS	;A LINKED LIST (LUCKILY) OF STRING ARRAYS IN LEAP, AND SO FORTH.
		;THIS IS SO STRING GARB COLLECTOR CAN FIND THEM ALL.

; BLOCK CONTROL TABLE INFORMATION
;THIS IS FOR SAIL'S CORE MANAGEMENT ROUTINES (CORGET,CORREL,CORINC...)

XX BLKTAB,3,3	;BASE OF BLOCK CONTROL TABLE
   XX LOWC	;LOW LIMIT OF ALLOCATABLE "BLOCK" CORE
   XX TOP	;UPPER LIMIT OF SAME
   XX FRELST	;POINTER TO BLOCK FREE STORAGE LIST

 XX XPAND	;PERMISSION TO EXPAND IN CORREL IF 0
 XX ATTOP	;REQUEST TO ALLOCATE OFF TOP OF CORE IF NON-0
 XX NOSHRK	;IF ON, CORREL NOT GIVEN PERMISSION TO SHRINK CORE
STANFO <
 XX USCOR2	;IF ON, CORGET WILL USE CORE2 ROUTINES.
>;STANFO

 XX BUFACS,10,,	;FOR BUFFER ALLOCATOR
STANFO <
XX ZAPEND,,1	;END OF SECOND SEGMENT AREA.
>;STANFO
CMU <
XX USCOR2		;THE COPYCATS
XX ZAPEND,,1		;ditto ZAPBEG
>;CMU

; INTERNAL VARIABLES FOR RE-ENTRANT ROUTINES

;;%  % DCS 12-3-73 New entries, delete some old ones (strngc) 
 XX STBUCK,1,1	;USED IN STRING GC TO KEEP TRACK OF BLOCKS
   XX OFFSET		;Distance to move a string space, see STRNGC
 XX STINCR		;String space increment size, see STRNGC
 XX STREQD		;String space threshold size, see STRNGC

 XX SGCCNT		;NUMBER OF TIMES STRNGC HAS BEEN CALLED
 XX SGCTIME		;Time of last GC if non-zero, else not enabled
 XX SGCTOTAL		;Total GC time while enabled (set SGCTIME -1 to enable)
 XX SGCNUM		;Number of strings collected last GC
 XX SGCWASTE		;Number of wasted words after last GC

 XX SRELOC
 XX CODAC		;SAVE AC 1 OVER CALLS ON "CODE" RUNTIME ROUTINE
 XX WDTH		;GLOBAL WIDTH FOR STRING CONVERSION ROUTNES
 XX DIGS		; "" FOR # OF DECIMAL DIGITS

; I/O INTERNAL VARIABLES

 XX CDBLOC	;IF CHNL IS A CH #, @CDBLOC(USER) GETS ITS CDB ADDR

 XX FNAME	;ENTER-LOOKUP TABLE
 XX EXT
 XX WD3
 XX PRPN
 XX LONGWD	;LONG FORM LOOKUPS AND ENTERS POKE THIS
 XX LONG2	; AND THIS -- FILEINFO ROUTINE GIVES TO USER

 XX PROJ		;USED BY FILNAM ROUTINE

; AC SAVE AREAS

 XX RACS,13,,	;RE-ENTRANT ROUTINES SAVE HERE
 XX SGACS,14,,	;AVAILABLE ANY TIME IF YOU ARE NOT
 		; LIKELY TO CALL STRNGC
 XX STACS,14,,	;YET ANOTHER AC SAVE AREA
 XX PGNNFL

;SOME STUFF FOR MULTIPLE PROCESSES

?NPRIS←←20	;NUMBER OF PRIORITIES
 XX PRILIS,NPRIS,, 	;PRIORITY LIST HEADERS
 XX GGDAD		;THE BASE FOR THE MAIN PROCESS (IF HAVE ONE)
 XX TIMER		;COUNTED DOWN FOR CLOCK INTERRUPTS
 XX SCHDRQ		;SET ≠0 FOR A SCHEDULER REQUEST
			;(USED BY EVENTS)
 XX STKURT		;PLACE FOR STACKUNWINDER RETN ADRS
 XX INTQWP		;INTERRUPT NOTICE BUFFER WRITE PTR
 XX INTQRP		;READ PTR
 XX INTQWT		;TOP OF BUFFER 
 XX INTQWB		;BOTTOM OF BUFFER
 XX INTPRC		;INTERRUPT PROCESS BASE
 XX DISPAT		;DISPATCH TABLE FOR INTERRUPT LEVEL MODULE
 XX DFRINF		; AOBJN PTR TABLE FOR DEFERRED INTERRUPTS
 XX IPDP		;INTERRUPT PDP
 XX IJBCNI		;JOBCNI FROM A DEFERRED INTERRUPT
 XX IJBTPC		;JOBTPC FROM DEFERRED INTERRUPT
 XX IRUNNR		;RUNNER AT TIME OF DEFERRED INTERRUPT
 XX ISPDP		;STRING PDP FOR INTERRUPT LEVEL
;;%##% RHT THESE FOR ADDED RUNTIMES
XX  BRKCVT		;UPPER CASE BREAK TABLE CONVERSION
XX  TTYCVT		; DITTO FOR TTY INPUT
XX  FSTATS		; FOR GETSTS
;;%##%  ADDING THESE
 XX SPARUT,05,,		;SPARE USER TABLE ENTRIES
 XX ENDREN	; END OF USER DATA TABLE

SUBTTL	Global AC Definitions, Indices, Bits

AC2DATA (GLOBAL AC ASSIGNMENTS)
?P	←17
?SP	←16
?USER	←15
?TEMP	←14
?LPSA	←13
?RF	←←12			;THE ALMIGHTY F REGISTER
?TAC1	←←TEMP
?TAC2	←←LPSA

BITDATA (BITS FOR %ALLOC SPACE REQUEST BLOCK ENTRIES)
?STDSPC ←←400000	;"INDIRECT" SPECIFICATION OF STANDARD AREA
?WNTADR ←←200000	;ADDRESS OF AREA TO BE STORED AS SPECIFIED
?WNTEND ←←100000	;ADDRESS OF NEXT AREA TO BE STORED AS SPECIFIED
?WNTPDP ←← 40000	;PDP TO AREA TO BE STORED " "
?WNTPDL ←← WNTPDP	;WNTPDP, WNTPDL -- WHAT'S THE DIFFERENCE?
?USRTB  ←← 20000	;RESULT ADDRESSES ARE IN THE USER TABLE
?MINSZ  ←← 10000	;THIS SIZE TO BE USED ONLY IF NO OTHERS GIVEN

BITDATA (INDICES OF STANDARDLY ALLOCATED AREAS (SEE %ALLOC))
?SYSPD	←← 1		;SYSTEM!PDL
?SYSSPD	←← 2		;STRING!PDL
?STRSP	←← 3		;STRING!SPACE

BITDATA (INDICES INTO THE FIXED PORTION OF EACH %ALLOC SPACE REQ. BLOCK)
?$ITNO	←←1		;MAX ITEM NUMBER DECLARED THIS COMPILATION
?$NWITM ←←2		;XWD REQUIRED BUCKETS,REQUIRE  NEW!ITEMS 
?$GITNO	←←3		;MAX (MIN?) GLOBAL ITEM NUMBER DECLARED
?$MSLNK	←←4		;POINTER TO MESSAGE PROCEDURE LIST PUT HERE
?$PNMNO	←←5		;REQUIRE n PNAMES PUTS n HERE
?$VRNO	←←6		;VERSION NUMBER
?$SGNM	←←7		;REQUIRED GLOBAL SEGMENT NAME (USUALLY EMPTY)
?$SGD	←←10		;REQUIRED GLOBAL SEGMENT FILE DEVICE
?$SGF	←←11		;" FILE NAME
?$SGPP	←←12		;" PPN
?$TINIT ←←13		; POINTER TO INITIAL ITEM TYPES
?$PINIT ←←14		; POINTER TO INITIAL PRINTNAMES

HACK <
;;##;; AT NEXT VERSION CHANGE, DO IT!
?$SPREQ	←← 15		;OFFSET OF SPACE REQUEST ENTRIES WITHIN SPACE BLOCKS

>;HACK
NOHACK <
?$CMVER ←← 15		;com version
?$SPREQ ←← 16		;ONE MORE
>;NOHACK
ENDDATA


BITDATA (LINK NAMES)
?%STLNK ←← 1
?%SPLNK ←← 2
?%SETLK ←← 3
?%SGROT ←← 4
?%KTLNK ←← 5
?%PDLNK ←← 6
?%INLNK ←← 7

BITDATA (PROCEDURE DESCRIPTOR INDICES)

	DEFINE PDX(I),
		<?I ←← PD.XXX
		PD.XXX←←PD.XXX+1
>
PD.XXX	←← 0
	PDX	PD.	;0
	PDX	PD.ID1	;1
	PDX	PD.ID2	;2
	PDX	PD.PDB	;3
	PDX	PD.NPW	;4
	PDX	PD.DSW	;5
	PDX	PD.LLW	;6
	PDX	PD.DLW	;7
	PDX	PD.PDA	;10
	PDX	PD.PPD	;11
	PDX	PD.PCW	;12
	PDX	PD.BDI	;13

?PD.XXX←←PD.XXX

BITDATA (TYPE CODES WITHIN RH OF INFOTAB ENTRY)
	NOTYPE ←← 1	;NO TYPE AT ALL
        BRKITM ←← 2	;BRACKETED TRIPLE
	STTYPE ←← 3	;STRING ITEM
	FLTYPE ←← 4	;REAL ITEM
	INTYPE ←← 5	;INTEGER ITEM
	LSTYPE ←← 7	;LIST ITEM (TYPE SHOULD ALWAYS BE 1 MORE THN SETYPE
	SETYPE ←← 6	;SET ITEM
	PITTYP ←← 10	;PROCEDURE ITEM
	PRCTYP ←← 11	;PROCESS ITEM
	EVTTYP ←← 12	;EVENT TYPE ITEM
	CTXTYP ←← 13	;CONTEXT ITEM
	RFITYP ←← 14	;REFERENCE ITEM
	INVTYP ←← 31	;NON-VALID TYPE CODE
	ARRTYP ←← 15	;ARRAYS ARE THIS PLUS SIMPLE TYPE CODE

BITDATA (USE OF THE RESERVED ITEMS)
; ANY IS REPRESENTED BY 0
	ITMANY ←← 0	;ITEM FOR ANY
	MAINPI ←← 1	;ITEM NUMBER OF THE MAIN PROCESS ITEM
	UNBND  ←← 2	;UNBOUND (?ITEMVARS ETC)
	EVTYPI ←← 3	;THE ITEM EVENT!TYPE
	NIC    ←← UNBND	;ITEM GET BACK FROM EMPTY NOTICE QUEUE
;;# # MAKE NIC & UNBOUND THE SAME ITEM -- RHT
;;     I.E. NULL INTERROGATIONS RETURN UNBOUND NOW

	?MAXLOC ←← =10	;MAXIMUM NUMBER OF LOCAL ITEMVARS IN FOREACH
	?QBIND ←← 200	;A ? ITMVR (NOT A MP PARM)
	?FBIND ←← 100	;A BIND ITMVR(HERE BECAUSE OF STATS)

BITDATA (THE NAMED BITS FOR REF ITEMS)
;;%BH% RHT ADD TEMP BIT
	?TMPB ←← 400000 ; SIGN BIT MEANS A TEMP REF ITEM
	?REFB ←← 200000	;USUALLY SET
	?QUESB ←← 100000;FOR ? ITEMVARS
	?BINDB ←← 40000	;FOR BIND ITEMVAR
	?PROCB ←← 20000	;NOT NOW REALLY USED
	?ITEMB ←← 10000	; AN ITEM (ITEMVAR)
	?ARY2B ←← 4000	;FOR * ARRAY ITEMVAR ARRAY REFERENCES
	?MSK6BT ←← 3740 ; BITS FOR SIX BIT TYPE
	?MSKUNT ←← 3700	;BIT MASK FOR UNTYPED 
ENDDATA

;;%AM% MANY USER PHASES 
 SYSPHS←←2			;TWO SYSTEM PHASES
 USRPHS←←3			;THREE USER PHASES (FOR NOW)
				; (0, 1, 2) -- 1 IS DEFAULT

IFN HEDSYM, <		;MAKE AN HONEST ASSEMBLY OUT OF IT
	TITLE	HEAD
	END
>;IFN HEDSYM